﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script>

        /*! jQuery JSON plugin 2.4.0 | code.google.com/p/jquery-json */
        (function ($) {
            'use strict'; var escape = /["\\\x00-\x1f\x7f-\x9f]/g, meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }, hasOwn = Object.prototype.hasOwnProperty; $.toJSON = typeof JSON === 'object' && JSON.stringify ? JSON.stringify : function (o) {
                if (o === null) { return 'null'; }
                var pairs, k, name, val, type = $.type(o); if (type === 'undefined') { return undefined; }
                if (type === 'number' || type === 'boolean') { return String(o); }
                if (type === 'string') { return $.quoteString(o); }
                if (typeof o.toJSON === 'function') { return $.toJSON(o.toJSON()); }
                if (type === 'date') {
                    var month = o.getUTCMonth() + 1, day = o.getUTCDate(), year = o.getUTCFullYear(), hours = o.getUTCHours(), minutes = o.getUTCMinutes(), seconds = o.getUTCSeconds(), milli = o.getUTCMilliseconds(); if (month < 10) { month = '0' + month; }
                    if (day < 10) { day = '0' + day; }
                    if (hours < 10) { hours = '0' + hours; }
                    if (minutes < 10) { minutes = '0' + minutes; }
                    if (seconds < 10) { seconds = '0' + seconds; }
                    if (milli < 100) { milli = '0' + milli; }
                    if (milli < 10) { milli = '0' + milli; }
                    return '"' + year + '-' + month + '-' + day + 'T' +
hours + ':' + minutes + ':' + seconds + '.' + milli + 'Z"';
                }
                pairs = []; if ($.isArray(o)) {
                    for (k = 0; k < o.length; k++) { pairs.push($.toJSON(o[k]) || 'null'); }
                    return '[' + pairs.join(',') + ']';
                }
                if (typeof o === 'object') {
                    for (k in o) {
                        if (hasOwn.call(o, k)) {
                            type = typeof k; if (type === 'number') { name = '"' + k + '"'; } else if (type === 'string') { name = $.quoteString(k); } else { continue; }
                            type = typeof o[k]; if (type !== 'function' && type !== 'undefined') { val = $.toJSON(o[k]); pairs.push(name + ':' + val); } 
                        } 
                    }
                    return '{' + pairs.join(',') + '}';
                } 
            }; $.evalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) { return eval('(' + str + ')'); }; $.secureEvalJSON = typeof JSON === 'object' && JSON.parse ? JSON.parse : function (str) {
                var filtered = str.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''); if (/^[\],:{}\s]*$/.test(filtered)) { return eval('(' + str + ')'); }
                throw new SyntaxError('Error parsing JSON, source is not valid.');
            }; $.quoteString = function (str) {
                if (str.match(escape)) {
                    return '"' + str.replace(escape, function (a) {
                        var c = meta[a]; if (typeof c === 'string') { return c; }
                        c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
                    }) + '"';
                }
                return '"' + str + '"';
            };
        } (jQuery));


        function Addtabs (final, tabs) {
            var x = tabs;
            var char = "    ";
            while (x--) {
                final = final + char;
            }
            return final;
        }

        $().ready(function () {

            $("#submit").click(function () {
                if ($("#content option:selected").text() == "JSON") {

                    $.ajax({
                        url: "[%URL%]",
                        data: $("form").serialize(),
                        success: function (data) {
                            var final = "";
                            var formatted = $.toJSON(data);
                            var i = formatted.length;
                            var len = i - 1;
                            var tabs = 0;
                            while (i--) {
                                var charachter = formatted[len - i];

                                if (charachter == "{") {
                                    final = final + "\n"
                                    final = Addtabs(final, tabs);
                                    tabs++;
                                    final = final + charachter + "\n";
                                    final = Addtabs(final, tabs); 
                                }
                                else if (charachter == "}") {
                                    final = final + "\n";
                                    tabs--;
                                    final = Addtabs(final, tabs);
                                    final = final + charachter + "\n";
                                    final = Addtabs(final, tabs);
                                }
                                else { 
                                    final = final + charachter;
                                }
                            }
                            $("#returns").text(final);

                        },
                        dataType: "json"
                    });

                    return false;
                }
                else {
                    return true;
                }
            });

        });
    </script>
</head>
<body>
    <pre>[%error%]</pre>


    <h3>Request Type: [%RequestType%]</h3>
    <br />
<h3>Test Form</h3>

    Content Type: <select id="content"><option selected="selected">HTML</option><option>JSON</option></select>

    <form method="[%RequestType%]" action="[%URL%]" enctype="multipart/form-data">
        [%fields%]
        
         <br /> File upload (only use for upload calls)<br />
        <input type="file"  name="additem_image"/>
        
        <input id="submit" type="submit" value="submit" />
          
    </form>
    
    <h3>Returns:</h3>
    <div id="returns" style="white-space:pre;"></div>
    
</body>
</html>
